﻿using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

[ExecuteInEditMode]
public class mTest2 : MonoBehaviour 
{
	public GameObject mirrorPlane;
	public GameObject objectInFrontOfMirror;

	void Start()
	{
		transform.position = objectInFrontOfMirror.transform.position;
		transform.rotation = objectInFrontOfMirror.transform.rotation;
		transform.localScale = -objectInFrontOfMirror.transform.localScale; 
		transform.RotateAround (
			objectInFrontOfMirror.transform.position, 
				mirrorPlane.transform.TransformDirection(new Vector3(0.0f, 1.0f, 0.0f)), 
					180.0f);

		Vector3 positionInMirrorSpace  = mirrorPlane.transform.InverseTransformPoint( objectInFrontOfMirror.transform.position);
		positionInMirrorSpace.y = -positionInMirrorSpace.y;
		transform.position = mirrorPlane.transform.TransformPoint( positionInMirrorSpace);
	}
}
